package br.usp.pcs.basys2.peripheral;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import br.usp.pcs.basys2.info.PeripheralInfo;

public class PeripheralManager {
	private Map<String,Peripheral> peripheralsMap = new HashMap<String, Peripheral>();

	public Peripheral get(Object arg0) {
		return peripheralsMap.get(arg0);
	}

	public Peripheral put(String peripheralName, Peripheral arg1) {
		return peripheralsMap.put(peripheralName, arg1);
	}
	
	public void setPeripherals(List<PeripheralInfo> peripheralInfoList) {
		for (PeripheralInfo info : peripheralInfoList) {
			this.put(info.getName(),new Peripheral(info));
		}
	}

	public void addListenerToPeripherals(PeripheralManagerListener e) {
		Collection<Peripheral> values = peripheralsMap.values();
		for (Peripheral p : values) {
			p.add(e);
		}
	}
	
}
